﻿Imports System.Web
Imports System.Web.Services

Public Class imageHandler
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        If Not String.IsNullOrEmpty(HttpContext.Current.Request.QueryString("imageID")) Then
            Dim imageID = HttpContext.Current.Request.QueryString("imageID")
            Dim db As New AuctionInfoDataContext
            Dim result = From img In db.Images _
                         Where img.imageID = imageID _
                         Select img.image


            HttpContext.Current.Response.BinaryWrite(CType(result.First.ToArray, Byte()))
            context.Response.End()
        End If
    End Sub

    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class